package com.wl.common.security.bean;


import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.wl.common.core.constant.SecurityConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author: wanglin
 * @date: 2023-11-06 周一
 * @Version: 1.0
 * @Description:
 */
@ConfigurationProperties(prefix = "jwt")
public class JwtProperties {
    /**
     * 'Bearer ' ,JWT负载中拿到开头
     */
    public String tokenHead;
    /**
     * 请求头，Authorization，JWT存储的请求头
     */
    public String tokenHeader;
    /**
     * 私秘钥
     */
    public String secret;
    /**
     * 过期时间，默认分钟
     */
    public Long expiration;
    /**
     * 缓存刷新时间，默认分钟，token过期前10分钟之内，刷新token
     */
    public Long refreshTime;

    public String getTokenHead() {
        return tokenHead;
    }

    public void setTokenHead(String tokenHead) {
        this.tokenHead = StrUtil.isNotBlank(tokenHead) ? tokenHead : SecurityConstants.TOKEN_PREFIX;
    }

    public String getTokenHeader() {
        return tokenHeader;
    }

    public void setTokenHeader(String tokenHeader) {
        this.tokenHeader = StrUtil.isNotBlank(tokenHeader) ? tokenHeader : SecurityConstants.AUTHENTICATION;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = StrUtil.isNotBlank(secret) ? secret : SecurityConstants.SECRET;
    }

    public Long getExpiration() {
        return expiration;
    }

    public void setExpiration(Long expiration) {
        this.expiration = ObjUtil.isNotNull(expiration) ? expiration : SecurityConstants.EXPIRATION;
    }

    public Long getRefreshTime() {
        return refreshTime;
    }

    public void setRefreshTime(Long refreshTime) {
        this.refreshTime = ObjUtil.isNotNull(refreshTime) ? refreshTime : SecurityConstants.REFRESH_TIME;
    }
}
